package com.zmc.admin.infrastructure.service.impl;

import com.zmc.common.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmc.common.utils.Query;

import com.zmc.admin.infrastructure.dao.SysUserRoleDao;
import com.zmc.admin.infrastructure.entity.SysUserRoleEntity;
import com.zmc.admin.infrastructure.service.SysUserRoleService;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author zmc
 */
@Service("sysUserRoleService")
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleDao, SysUserRoleEntity> implements SysUserRoleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SysUserRoleEntity> page = this.page(
                new Query<SysUserRoleEntity>().getPage(params),
                new QueryWrapper<SysUserRoleEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void deleteUserRoleByUserId(Long userId) {
        baseMapper.deleteUserRoleByUserId(userId);
    }

    @Override
    public void deleteUserRoleByUserIds(Long[] userIds) {
        baseMapper.deleteUserRoleByUserIds(userIds);
    }

    @Override
    @Transactional
    public void insertBatch(List<SysUserRoleEntity> userRoleList) {
        baseMapper.insertBatch(userRoleList);
    }

    @Override
    public void insertUserRole(SysUserRoleEntity userRole) {
        baseMapper.insertUserRole(userRole);
    }

}